<template>
	<view>
		<view class="cu-custom" :style="[{height:CustomBar + 'px'}]">
			<view class="cu-bar fixed" :style="style"  >
				<view class="action" @tap="BackPage" v-if="isBack&&isHome==0">
					<text class="cuIcon-back"></text>
					<slot name="backText"></slot>
				</view>
				<view class="content" :style="[{top:StatusBar + 'px'}]">
					<slot name="content"></slot>
				</view>
				<slot name="right"></slot>
			</view>
		</view>
		<view class="col" v-if="isHome==1">
			<view class="goHome row bg-cyan"  @click="go()">前往首页</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				StatusBar: this.StatusBar,
				CustomBar: this.CustomBar,
				style:""
			};
		},
		created(){
			this.styles()
		},
		props: {
			bgColor: {
				type: String,
				default: ''
			},
			isBack: {
				type: [Boolean, String],
				default: false
			},
			bgImage: {
				type: String,
				default: ''
			},
			isHome: {
				type: Number,
				default: 0
			},
			bgCol: {
				type: String,
				default: ""
			},
			page:{
				type: String,
			}
		},
		watch:{  
            bgCol(newVal, oldVal){  
				this.styles()
            }  
        },
		methods: {
			BackPage() {
				uni.navigateBack({
					delta: 1
				});
			},
			styles() {
				var StatusBar= this.StatusBar;
				var CustomBar= this.CustomBar;
				var bgImage = this.bgImage;
				var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
				if (this.bgImage) {
					style = `${style}background-image:url(${bgImage});`;
				}
				if (this.bgCol) {
					style = `${style}background:${this.bgCol}!important;`;
				}
				this.style=style
				return style
			},
			go(){
				console.log(this.page);
				uni.reLaunch({
					//  url: this.page
					 url: "/pages/home/home"
				});
			}
		}
	}
</script>

<style lang="scss">
	.cu-bar{
		background: $main_col !important;
	}
	.cuIcon-back,.cu-bar{
		color:#fff;
	}
	.goHome{
		position: fixed;
		bottom:100rpx;
		z-index: 999999999999;
		width: 300rpx;
		height: 80rpx;
		border-radius: 100rpx;
		justify-content: center;
		// background: $main_col;
	}
</style>
